package com.neno.service;

import com.neno.dao.UserDao;
import com.neno.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class UserService {
    @Autowired
    private UserDao userDao;

    public List<User> selectUsers() {
        return userDao.selectUsers();
    }

    public User getUser(String email) {
        return userDao.getUserById(email);
    }

    @Transactional
    public int deleteUser(String email) {
        return userDao.deleteUserById(email);
    }

    @Transactional
    public int updateUser(User user) {
        return userDao.updateUser(user);
    }

    @Transactional
    public int insertUser(User user) {
        return userDao.insertUser(user);
    }

    public User getUser(String name, String password) {
        return userDao.getUserByNameAndPassword(name, password);
    }
}
